import { Injectable } from '@angular/core';
import { DataStore } from './dataStore';
import { Http } from '@angular/http';
import { map } from "rxjs/operators";
import { Observable } from 'rxjs/Observable';

@Injectable()
export class GetEchartDataService {
  public dataStore: DataStore = new DataStore();
  constructor(private http: Http) { }
  public getData(): Observable<DataStore> {
    let that = this;
    return this.http.get("modules/mockdata/data.json").pipe(map(data => {
      // 返回的data是带有请求体的
      that.dataStore.data = data.json();
      that.dataStore.ret = 'ok';
      that.dataStore.msg = '';
      return that.dataStore;
    })); //map(data => {}
  }
}
